<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/commons/include/html_doctype.html"%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <%@include file="/commons/page/codegen.jsp"%>
<%--     <link href="${ctx}/js/gpoint/rdp/zone/css/bootstrap.min.css" rel="stylesheet" /> --%>
    <link href="${ctx}/js/gpoint/rdp/zone/css/bootstrap-duallistbox.min.css" rel="stylesheet" />
    
   <script src="${ctx}/js/gpoint/rdp/zone/jquery-3.0.0.min.js"></script>
    <script src="${ctx}/js/gpoint/rdp/zone/bootstrap.min.js"></script>
    <script src="${ctx}/js/gpoint/rdp/zone/jquery.bootstrap-duallistbox.js"></script>
       <link type="text/css" rel="stylesheet" href="${ctx}/js/gpoint/rdp/zone/css/bootstrap.css">

<script type="text/javascript" src="${ctx}/js/gpoint/rdp/zone/bootstrap-paginator.js"></script>
<script type="text/javascript" src="${ctx}/js/gpoint/rdp/TimeSegment/timeSeg.js"></script>
</head>

<body>

<div class="panel panel-default">
    <div class="panel-heading">
      <!--   不带 title 的面板标题 --> 时间段选择
    </div>
    <div class="panel-body">
     <!--    面板内容 -->
	 <div class="toolbar-body" >
	      
						<form role="form" class="search-form">
						  
							<div  class="form-inline p-xxs">	
							    <div class="form-group">
										   请选择 时间段<select id="datasetProperty" onchange="cge()">  </select>
								</div>
														
								<div class="form-group">
										<label class="search-label" >开始日期 </label>:	<input reayonly="reayonly" type="text" name="s1"  id="s1"   />
								</div>
								<div class="form-group">
									<label class="search-label" >结束日期 </label>:	<input  reayonly="reayonly" type="text" name="s2"  id="s2" />
								</div>	
								
								<div class="form-group">
										 <a id="showValue3" class="btn btn-primary fa fa-search" href="javascript:void(0);" ><span>允许</span></a>
								</div>		
								
								<div class="form-group">
										 <a id="showValue4" class="btn btn-primary fa fa-search" href="javascript:void(0);" ><span>明细</span></a>
								</div>	
								
														
							</div>
						</form>
					</div><!--/ 查询条件-->
    </div>
</div>
 
 

   <div class="row" >
        <div class="col-lg-6 " >
		        <div class="panel panel-default">
				    <div class="panel-heading">
				        用户选择
				    </div>
				    <div class="panel-body">
				    
										       <div class="col-md-12">
				
				
				
<div class="panel panel-default">
   
    <div class="panel-body">
    
	 <div class="toolbar-body" >
	      
						
						  
							<div  class="form-inline p-xxs">	
							    <div class="form-group">
										<label>部门</label>
								</div>
														
								
								<div class="form-group">
									
												<input name="orgcode" type="hidden" id="hid_orgcode" class="fr-form-control" value="" />							
							                     <input type="text" data-key="#hid_orgcode" readonly="readonly" class="form-control comboTree" data-toggle="dictionary" data-url="${ctx}/rdp/card/department/department/list_json_tree.htm?typecode=parent"  />
								</div>	
								
								<div class="form-group">
										 <label>学工号</label>
								</div>		
								<div class="form-group">
										<input type="text" id="student">
										
										
											  <button  onclick="querystudent()" > 查询 </button>
								</div>							
							</div>
						
	      
								
	      
	      
					</div><!--/ 查询条件-->
    </div>
</div>
 
 
 
 
 
						        <select multiple="multiple" size="10" name="duallistbox_demo1" class="demo1">
						        </select>
						       
						       <ul class="pagination"  id="page"></ul>
						                    </div>
    
				    </div>
				</div>

        </div>
        <div class="col-lg-6 ">
		        <div class="panel panel-default" >
					    <div class="panel-heading">
					        控制器选择
					    </div>
					    <div class="panel-body" style="height:570px;" >
								     <div class="col-md-12"  >
								     
								     				
<div class="panel panel-default">
  
    <div class="panel-body">
    
	 <div class="toolbar-body" >
	      
						
						  
							<div  class="form-inline p-xxs">	
							    <div class="form-group">
										<label>区域</label>
								</div>
														
								
								<div class="form-group">
									      <input name="m:doorController:zoneid" type="hidden"   id="hid_zoonid" value="${doorController.zoneid}"/>						    					
								    <input type="text" data-key="#hid_zoonid" readonly="readonly"  class="form-control comboTree" data-toggle="dictionary" data-url="${ctx}/rdp/area/zone/list_json_tree.htm?" value="${doorController.zonename}"  validate="{required:true}"/>
							    </div>
								<div class="form-group">
										<label>控制器</label>
								</div>		
								<div class="form-group">
																<input type="text" id="ctl">
																  <button  onclick="queryctl()" > 查询 </button>
															
								</div>							
							</div>
						
	      
								
	      
	      
					</div><!--/ 查询条件-->
    </div>
</div>


											        <select multiple="multiple" size="10" name="duallistbox_demo2" class="demo2">
											        </select>
				      
											         <ul  class="pagination"  id="page"></ul>
											    </div>
						            </div> 
						            
						            
						               
						                    
						                    
						                    
				</div>

        </div>
    </div>

 </div>
 
 


  
 
 


    
    
 
</body>



<script type="text/javascript">

 <%--  var __ctx = '<%=path%>'; --%>
function appendHtml(returnData) {//此函数用于处理后台返回的数据，根据自己需求来实现页面拼接
	  var objs = $.parseJSON( JSON.stringify(returnData));
    
	  if(objs==null ){
		  alert("用户数据获取异常！");
		   return;
		  
	  }else{
		  var json = [];
		  
		  
	      $(objs).each(function () {
	    	  
	    	   
	    	   
	           var objA=objs.rows;    
	           for(var i=0;i<objA.length;i++){
	          	  var o = document.createElement("option");
	          	 
	          	 // alert(objA[i]['test']);
	          	  // o.value =objA[i]['key'];
	          	  
	          
	               //o.text =  objA[i]['value'];
	             //  o.text =  "001 &nbsp;  "+"|"+"    &nbsp;   56789      |"+"  &nbsp;  |"+"abcdc  " ;
	             //	  o.value = objA[i]['test'];
	              //o.text = objA[i]['test'] ;
	            //  alert(o.text);
	           //   alert(label);
	              
	                var label = objA[i]['key'];
	                
	                console.log(label);
	                
	                
                   var value = objA[i]['value'];
              
                
                
                var  flag=objA[i]['selectedflag'];
                
                if(!flag){ //flase 
                
                 $('.demo1').append('<option value="' + value + '">' + label + '</option>');
                }else{
             	   $('.demo1').append('<option value="' + value +'" selected="selected">' +label + '</option>');
                }
	              
	              
	              
	              
	           }
	           
	           /* for (var i in json) {
	                var item = json[i];
	                $('.demo1').append('<option value="' + item.value + '">' + item.label + '</option>');
	            }; */
	            
	            
	            
	           //$("." + 'demo1' + "")[0].options.add(o);
	           
	           
	           
	           
	           
	           
	         
	           $('.demo1').bootstrapDualListbox('refresh');
	         
	      });      //渲染dualListbox
	      $('.' + 'demo1' + '').bootstrapDualListbox({
	          nonSelectedListLabel: '人员列表 ',
	          selectedListLabel: '已选择授权人数：',
	          preserveSelectionOnMove: 'moved',
	          moveOnSelect: false//,
	          //nonSelectedFilter: 'ion ([7-9]|[1][0-2])'
	      });
	  }
	 
	 
      
}

var __ctx=_ctx;
//alert(${__ctx});
function appendHtml2(returnData) {//此函数用于处理后台返回的数据，根据自己需求来实现页面拼接
	  var objs = $.parseJSON( JSON.stringify(returnData));
	///  alert("aaa");
  
	  if(objs==null ){
		  alert("门数据获取异常！");
		   return;
		  
	  }else{
		  $(objs).each(function () {
		       
		         var objA=objs.rows;    
		         
		         var json = [];
                 
                 $(objA).each(function () {
                     var o = document.createElement("option");
                   /*   o.value = this['controllerid']+","+this['doorname'];
                    
                     o.text =this['key'];
                     console.log(this['key']); */
                  
                     var label = this['key'];
 	                
 	                console.log(label);
 	                
 	                
 	               var value = this['doorno']+","+this['doorname'];
                
                 
                    var  flag=this['selectedflag'];
                    
                    if(!flag){ //flase 
                    
                     $('.demo2').append('<option value="' + value + '">' + label + '</option>');
                    }else{
                 	   $('.demo2').append('<option value="' + value +'" selected="selected">' +label + '</option>');
                    }
                 });
                 
               
 	            
 	            
 	            
		       
		         $('.demo2').bootstrapDualListbox('refresh');
		       
		    });      //渲染dualListbox
		    $('.' + 'demo2' + '').bootstrapDualListbox({
		    	  nonSelectedListLabel: '门列表',
		          selectedListLabel: '已选择门数：',
		          preserveSelectionOnMove: 'moved',
		          moveOnSelect: false//,
		    });
	  }
   
    
}




$(function() {
	
	//alert("分页预加载中...");
	 pageStart();//开始分页
			
	 function pageStart() {//分页函数
	    $.ajax({ //去后台查询第一页数据
			type : "get",
			url : __ctx+"/rdp/user/campusCard/listJson",
			dataType : "json",
			data : {page : '1'}, //参数：当前页为1
			success : function(data) {
					
				
				//需要增加异常处理
				
			  appendHtml(data);//处理第一页的数据
				
			  var options = {//根据后台返回的分页相关信息，设置插件参数
				bootstrapMajorVersion : 3, //如果是bootstrap3版本需要加此标识，并且设置包含分页内容的DOM元素为UL,如果是bootstrap2版本，则DOM包含元素是DIV
				currentPage : data.page, //当前页数
				totalPages : data.total, //总页数
				numberOfPages : 20,//每页记录数
				itemTexts : function(type, page, current) {//设置分页按钮显示字体样式
					switch (type) {
					case "first":
						return "首页";
					case "prev":
						return "上一页";
					case "next":
						return "下一页";
					case "last":
						return "末页";
					case "page":
						return page;
					}
				},
			  onPageClicked : function(event, originalEvent, type, page) {//分页按钮点击事件
				
				$.ajax({//根据page去后台加载数据
					url : __ctx+"/rdp/user/campusCard/listJson",
					type : "get",
					dataType : "json",
					data : {"page" : page,"rows":20},
					success : function(data) {
						
						  $("." + 'demo1' + "").empty();
						  
							/*   $('.demo1').bootstrapDualListbox({
									
								  removeAllLabel: '移除全部option',//移除全部option按钮的label，默认'Remove all'
								  
								}); */
							//  $("." + 'demo1' + "")[0].options.remove();
							   $('.demo1').bootstrapDualListbox('removeSelectedLabel');
							 //  $('.demo1').bootstrapDualListbox('setMoveAllLabel', "");
							   $('.demo1').bootstrapDualListbox('setMoveAllLabel','', true);
							 //  $('.demo1').bootstrapDualListbox('destroy');
							 
							 
						appendHtml(data);//处理数据
				     
					}
				});
			  }
		    };
			$('#page').bootstrapPaginator(options);//设置分页
			}
		});
	}
	 
	 
	
	 
	 
	  
	});
	
	
	


function a(caruid){
	  var strs = new Array(); //定义一数组
	  
	   strs =  String(caruid).split(","); //字符分割

	  
	   var b=[];
	   for (i=0; i<strs.length; i++ ){
	        
		   if(i%2==0){  
			   if(i==0){
				  
				   b.push(String (strs[i])+","+strs[i+1]+"|");
			   }else{
				 
				  
				   b.push(String (strs[i])+","+strs[i+1]+"|");
			   }
			   
		   }
	   }
	   console.log(b);
	   return b;
	  //end
}



function getendDate(){

	   var myDate = new Date();

	    //获取当前年
	   var year = myDate.getFullYear()+10;

	   //获取当前月
	   var month = myDate.getMonth() + 1;

	    //获取当前日
	    var date = myDate.getDate();
	    var h = myDate.getHours(); //获取当前小时数(0-23)
	    var m = myDate.getMinutes(); //获取当前分钟数(0-59)
	    var s = myDate.getSeconds();

	   //获取当前时间

	   //var now = year + '-' + conver(month) + "-" + conver(date) ;
	   var now = year + '' + conver(month) + "" + conver(date) ;
	   return now;

	}
	
	
	

function getCurDate(){

	   var myDate = new Date();

	    //获取当前年
	   var year = myDate.getFullYear();

	   //获取当前月
	   var month = myDate.getMonth() + 1;

	    //获取当前日
	    var date = myDate.getDate();
	    var h = myDate.getHours(); //获取当前小时数(0-23)
	    var m = myDate.getMinutes(); //获取当前分钟数(0-59)
	    var s = myDate.getSeconds();

	   //获取当前时间

	   //var now = year + '-' + conver(month) + "-" + conver(date) ;
	   var now = year + '' + conver(month) + "" + conver(date) ;
	   return now;

	}
	
	

function getDate(){

	   var myDate = new Date();

	    //获取当前年
	   var year = myDate.getFullYear();

	   //获取当前月
	   var month = myDate.getMonth() + 1;

	    //获取当前日
	    var date = myDate.getDate();
	    var h = myDate.getHours(); //获取当前小时数(0-23)
	    var m = myDate.getMinutes(); //获取当前分钟数(0-59)
	    var s = myDate.getSeconds();

	   //获取当前时间

	   var now = year + '-' + conver(month) + "-" + conver(date) + " " + conver(h) + ':' + conver(m) + ":" + conver(s);

	}

	//日期时间处理
	function conver(s) {
	return s < 10 ? '0' + s : s;
	}
	
	
	
	//alert 执行
	$("#showValue4").click(function () {
		//alert("查询时间段明细");
		
		//得到当前选择数值
		  curselectedindex=selectvalue;
		
		//alert("curselectedindex="+curselectedindex);
		//弹框 赋初值
		 //弹框
			    DialogUtil.dialog(
					 {
			 				title : "时间段明细查询",
			 				content : __ctx+'/rdp/zone/doorZone/timeSegDetail?id='+curselectedindex,
			 				area : [ '1000px', '820px' ],
			 				maxmin : false,
			 				end : function() {
								
							}
			 			
			 		}
			 ); 
		
		//显示diaglog
		
		
		
		
	});
	
	
	
$("#showValue3").click(function () {
	//alert("授权进行");
	//得到第一个列表
       
	 //
	   var caruid=$('[name="duallistbox_demo1"]').val();
	//   alert("carduid="+caruid);
	
	//    alert(typeof(caruid));
	  //截取字符串
	  
	    b= a(caruid);
	   
	// alert(b);
	//得到门列表
	  var doorlist=$('[name="duallistbox_demo2"]').val(); 
	  
	  //alert("doorlist="+doorlist);
	   c= a(doorlist);
	  //alert(c);
	  
	  
	  alert("selectvalue="+selectvalue);
	   var startDate;
	   var endDate;
	  if(selectvalue==0){
		  
	    	  startDate=getCurDate();
	          endDate=getendDate();
	       
	          
	          
	      //    alert("开始时间="+startDate+"结束时间"+endDate);
	     }else{
	    //	 alert("selectvalue"+selectvalue);
	    	/*   startDate=selectvalue.split(',')[0];
	          endDate=selectvalue.split(',')[1];
	    
	    	
	    	//将时间戳转变成日期格式
	    	startDate=getMyDate(Number(startDate));
	    	endDate=getMyDate(Number(endDate)); */
	    	
	    	startDate=$("#s1").val();
	    	endDate=$("#s2").val();
	    //	alert("转义后的开始日期："+startDate+" "+"结束日期"+endDate);
	     } 
	  
		if(caruid.length!=0 && doorlist.length!=0){
			 //拼成JSON数组传递
			   var str = [];
				    		   var userArr= b; //id，卡号，姓名
				    		  // var doorArr = ["111","222"]; //控制器SN号，门号
				    		   var doorArr = c; //控制器SN号，门号
				    		  var map ={};
				    		   map.useArr = userArr;
				    		   map.doorArr =doorArr;
				    		//   map.startTime="2018-01-01";
				    		   map.startTime=startDate;
				    	       map.endTime=endDate;
				    	       map.str=index;
				    	       

  		    	         	 $.ajax({
  		    	         	type: "post",
  		    	         	   url: __ctx+"/rdp/CurrentPermission/currentPermission/query",
  		    	         	    contentType: "application/json;charset=utf-8;",
  		    	         	  data:JSON.stringify(map),
  		    	         	  dataType:"json",//注意不是datatype哦
  		    	         	    async: false,//使用同步操作，否则init方法执行时setting可能还未被赋值
  		    	         	   success: function(data) {
  		    	         		  console.log(data);
  		    	         	       //  alert("查询用户信息成功！");
  		    	         	 
  		    	         	 
  		    	         	if(data.result==0){ //不存在

	    		    	           $.ajax({
	    		    	         	type: "post",
	    		    	         	   url: __ctx+"/rdp/CurrentPermission/currentPermission/save3",
	    		    	         	    contentType: "application/json;charset=utf-8;",
	    		    	         	  data:JSON.stringify(map),
	    		    	         	  dataType:"json",//注意不是datatype哦
	    		    	         	    async: false,//使用同步操作，否则init方法执行时setting可能还未被赋值
	    		    	         	   success: function(data) {
	    		    	         	          alert("用户卡绑定成功！");
	    		    	         	  },
	    		    	         	 error: function(){
	    		    	         		  alert("用户卡绑定失败！");
	    		    	              }
	    		    	         	 
	    		    	         	 }); 
	    		    	         	 //end
		    	         	   }else		   if(data.result==1){//存在
		    	         		  //提示信息
		    	         	        DialogUtil.confirm(data.message + ',是否继续操作',
										function(rtn) {
										if(rtn){
											window.location.reload(true);
													   //更新入库
													     $.ajax({
				    		    	         	type: "post",
				    		    	         	   url: __ctx+"/rdp/CurrentPermission/currentPermission/update",
				    		    	         	    contentType: "application/json;charset=utf-8;",
				    		    	         	  data:JSON.stringify(map),
				    		    	         	  dataType:"json",//注意不是datatype哦
				    		    	         	    async: false,//使用同步操作，否则init方法执行时setting可能还未被赋值
				    		    	         	   success: function(data) {
				    		    	         	          alert("用户卡绑定成功！");
				    		    	         	  },
				    		    	         	 error: function(){
				    		    	         		  alert("用户卡绑定失败！");
				    		    	              }
				    		    	         	 
				    		    	         	 }); 
													     //end
										}   
										else{
											
										}
									    	
										});
		    	         	   }else{
		    	         		   
		    	         	   }
  		    	         	
  		    	         	
  		    	           
  		    	           
  		    	           
  		    	         	  },
  		    	         	 error: function(){
  		    	         		 alert("查询用户信息失败！");
  		    	              }
  		    	         	 
  		    	         	 }); 
  		    	         	 //end
				    	       
		    		  /* 
		    		    	         	 $.ajax({
		    		    	         	type: "post",
		    		    	         	   url: __ctx+"/rdp/CurrentPermission/currentPermission/save3",
		    		    	         	    contentType: "application/json;charset=utf-8;",
		    		    	         	  data:JSON.stringify(map),
		    		    	         	  dataType:"json",//注意不是datatype哦
		    		    	         	    async: false,//使用同步操作，否则init方法执行时setting可能还未被赋值
		    		    	         	   success: function(data) {
		    		    	         	          alert("用户卡绑定成功！");
		    		    	         	  },
		    		    	         	 error: function(){
		    		    	         		  alert("用户卡绑定失败！");
		    		    	              }
		    		    	         	 
		    		    	         	 }); 
		    		    	         	 //end */
		}else{
			alert("必须填完才能进行保存，不能进行类型授权操作");
		}
	  
	  
 
    
     
});





//下拉栏表框初始化初始化      
//初始化赋值
var selectvalue;
$(function () {
    //初始化
    initList('hangwei.cnblogs.com', 'demo1');
    selectvalue = $("#datasetProperty").val();
    
   
 
 
});


//时间控件表框初始化初始化      
//初始化赋值
$(function () {
  //初始化
  initdate(0);




});

function initList(queryParam1,selectClass, selectedDataStr) {
	//alert("时间段初始化");
    var paramData = {
        'testParam1': queryParam1
    }
    $.ajax({
        url: __ctx+"/rdp/TimeSegment/timeSeg/getData",
        type: 'get',
        data: paramData,
        async: false,
        success: function (returnData) {
        	console.log(returnData);
            var objs = $.parseJSON( JSON.stringify(returnData));
      
           
          var html = "";
           $('#datasetProperty').append("<option value='0'  checked='checked'>--任意时间有效--</option>");
            for (var i in objs) {
            	html += '<option value=' + objs[i].timeseg  + '>' + objs[i].timeseg + '</option>'
            }
            $("#datasetProperty").append(html); //渲染
        },
        error: function (e) {
            alert(e.msg);
        }
    });
}
//下拉栏表框初始化完毕    




function initdate(ctl) {
	 // alert(" 查询时间段,请稍等...");
	   
	 if(ctl==0){
		 //  alert("查询时间段默认为当前时间");
		 startDate=getCurDate();
	          endDate=getendDate();
		   $("#s1").val( startDate);//jquery通过id属性并修改value属性为123
	      $("#s2").val(endDate); 
	 }else{
				//获取信息
			      // var ctl= 1;
			     //发送ajax请求
			$.ajax({
		    url: __ctx+"/rdp/TimeSegment/timeSeg/querytime",
		    type: 'get',
		    data : {ctl : ctl}, //参数：当前页为1
		    async: false,
		    success: function (data) {
		    	       console.log(data);
		    	      appendHtml3(data);
		    	      
		    },
		    error: function (e) {
		        alert(e.msg);
		    }
});
		 
	 }
	     
	     
     //结果赋值
}

function appendHtml3(returnData) {//此函数用于处理后台返回的数据，根据自己需求来实现页面拼接
	  var objs = $.parseJSON( JSON.stringify(returnData));

  $(objs).each(function () {
     
       var objA=objs.rows;    
       for(var i=0;i<objA.length;i++){
    	   var s1=objA[i]['startdate'];
    	   var s2=objA[i]['enddata'];
    	    $("#s1").val( getMyDate(s1));//jquery通过id属性并修改value属性为123
    	    $("#s2").val(getMyDate(s2)); 
          
       }
     
      
     
  });     
 
  
}

//时间控件初始化完毕



     
         
   //第二个列表框初始化      
        //初始化赋值
      $(function () {
            //初始化
            initListBox2('hangwei.cnblogs.com', 'demo2');

            $("#showValue2").click(function () {
                alert($('[name="duallistbox_demo2"]').val());
            });
        });
        /*初始化duallistbox*/
        //queryParam1：参数
        //selectClass：select元素class属性
        //selectedDataStr：选中数据，多个以,隔开
        function initListBox2(queryParam1,selectClass, selectedDataStr) {
            var paramData = {
                'testParam1': queryParam1
            }
            $.ajax({
                url: __ctx+"/rdp/door/door/getData",
                type: 'get',
                data: paramData,
                async: true,
                success: function (returnData) {
                    var objs = $.parseJSON( JSON.stringify(returnData));
                 //   alert("aaaa");
                  // console.log(objs);
                  
                    var json = [];
                    
                    $(objs).each(function () {
                        var o = document.createElement("option");
                        
                  
                        var label = this['key'];
    	                
    	                console.log(label);
    	                
    	                
                       var value = this['doorno']+","+this['doorname'];
                   
                       var  flag=this['selectedflag'];
                      
                       if(!flag){ //flase 
                       
                        $('.demo2').append('<option value="' + value + '">' + label + '</option>');
                       }else{
                    	   $('.demo2').append('<option value="' + value +'" selected="selected">' +label + '</option>');
                       }
                      
                    });
                    
                    
               
    	            
                    //渲染dualListbox
                    $('.' + selectClass + '').bootstrapDualListbox({
                        nonSelectedListLabel: '门列表 ',
                        selectedListLabel: ' 已选择门数：',
                        preserveSelectionOnMove: 'moved',
                        moveOnSelect: false//,
                        //nonSelectedFilter: 'ion ([7-9]|[1][0-2])'
                    });
                },
                error: function (e) {
                    alert(e.msg);
                }
            });
        } 
//第二个列表框初始化完毕
      
var index;
  function cge(){
    var sel=document.getElementById('datasetProperty');
            var sid=sel.selectedIndex;
  //  alert(sel[sid].value+'-'+sel[sid].innerHTML);
     index=sel[sid].innerHTML;
  //  alert("index="+index);
    selectvalue=sel[sid].value;
  
   //alert("获取选择数值="+selectvalue);
      initdate(selectvalue);
}      
   
  
  
  function getMyDate(str){  
	        var date = new Date(str),  
	        oYear = date.getFullYear(), //年  
	        oMonth = date.getMonth()+1, //月  
	        oDay = date.getDate(),  //日
	        h = date.getHours(),//小时
	        m = date.getMinutes(),//分钟
	        s = date.getSeconds();//秒数
	        // 以自己需要的方式拼接
	   //     var oTime = oYear +'-'+ getZero(oMonth) +'-' + getZero(oDay)+' ' + getZero(h) + ':' +  getZero(m)+ ':' +  getZero(s);//最后拼接时间  
	       var oTime = oYear +''+ getZero(oMonth) +'' + getZero(oDay);     
	         return oTime;  
	      }

  function   getZero(num){  
	        // 单数前面加0
	        if(parseInt(num) < 10){  
	          num = '0'+num;  
	        }  
	        return num;  
	      }
	     
	  
	  function   querystudent(){  
		     
		//  alert(" 查询学生信息");
	   
	     //获取信息
	       var sno= $("#student").val();
	       var deptno=$("#hid_orgcode").val();
	     //发送ajax请求
	       $.ajax({
        url: __ctx+"/rdp/user/campusCard/querysno",
        type: 'get',
        data : {sno : sno,deptno:deptno}, //参数：当前页为1
        async: false,
        success: function (data) {
        	       console.log(data);
        	      
        	       $("." + 'demo1' + "").empty();
					  
					   $('.demo1').bootstrapDualListbox('removeSelectedLabel');
					 //  $('.demo1').bootstrapDualListbox('setMoveAllLabel', "");
					   $('.demo1').bootstrapDualListbox('setMoveAllLabel','', true);
					   
        	       appendHtml(data);
        	      
        },
        error: function (e) {
            alert(e.msg);
        }
    });
	     
	     //结果赋值
	     
	     
		      }  
	  
	  
	  //查询控制器
	  function   queryctl(){  
		     
		//  alert(" 查询控制器信息,请稍等...");
	   
	     //获取信息
	       var ctl= $("#ctl").val();
	       var zoneid= $("#hid_zoonid").val();
	      
	     //发送ajax请求
	       $.ajax({
        url: __ctx+"/rdp/door/door/query",
        type: 'get',
        data : {ctl : ctl,zoneid:zoneid}, //参数：当前页为1
        async: false,
        success: function (data) {
        	       console.log(data);
        	      
        	       $("." + 'demo2' + "").empty();
					  
					   $('.demo2').bootstrapDualListbox('removeSelectedLabel');
					
					   $('.demo2').bootstrapDualListbox('setMoveAllLabel','', true);
					   
					   appendHtml2(data);
        	      
        },
        error: function (e) {
            alert(e.msg);
        }
    });
	     
	     //结果赋值
	     
	     
		      }  
	  
	  
	  
    </script>
</html>
